package com.java.miaosha.controller;

import com.java.miaosha.constants.Constants;
import com.java.miaosha.service.UserService;
import com.java.miaosha.util.RegexUtils;
import com.java.miaosha.util.Result;
import com.java.miaosha.vo.LoginVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 用户表
 *
 * @author jiangli
 * @email 31346337@qq.com
 * @date 2019-08-30 21:15:08
 */
@Controller
@RequestMapping("/login")
public class LoginController extends BaseController{
    @Autowired
    private UserService userService;

    @GetMapping("/to_login")
    public String toLogin() {
        return "login";
    }

    @PostMapping("/do_login")
    @ResponseBody
    public Result doLogin(@Valid LoginVO loginVO) {
        return userService.login(loginVO,request,response);
    }
}
